/* Reset and base styles for iframe compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    overflow-x: hidden;
    /* Responsive height - 450px for iframe, 90vh for full browser */
    height: 450px;
    width: 100%;
}

/* Media query for full browser tab */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main game container with full width and height */
#gameContainer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 8px;
    gap: 8px;
}

/* Progress bar at the top - cognitive load principle */
#progressBar {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 6px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#progressFill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    border-radius: 20px;
    width: 0%;
    transition: width 0.5s ease;
}

#progressText {
    position: relative;
    z-index: 2;
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

/* Main story area - central focus principle */
#storyArea {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 120px;
}

#storyImage {
    text-align: center;
    padding: 10px;
}

.tap-icon {
    font-size: 48px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

#storyText {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    text-align: center;
}

/* Navigation panel with four tap buttons */
#navigationPanel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 5px;
}

.tap-button {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 60px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tap-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-color: #2196f3;
}

.tap-button:active {
    transform: translateY(0);
}

.tap-button.discovered {
    background: linear-gradient(145deg, #e8f5e8, #c8e6c9);
    border-color: #4caf50;
}

.tap-emoji {
    font-size: 24px;
}

.tap-name {
    font-size: 11px;
    font-weight: bold;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

/* Decision buttons for story choices */
#decisionPanel {
    display: flex;
    gap: 10px;
    padding: 0 5px;
}

.decision-button {
    flex: 1;
    background: linear-gradient(145deg, #2196f3, #1976d2);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-height: 36px;
}

.decision-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(33, 150, 243, 0.3);
}

/* Inventory panel showing discovered items */
#inventoryPanel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}

.inventory-title {
    font-size: 11px;
    font-weight: bold;
    color: #666;
    white-space: nowrap;
}

#inventoryItems {
    display: flex;
    gap: 6px;
    flex: 1;
}

.inventory-item {
    width: 28px;
    height: 28px;
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4caf50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.3s ease;
}

.inventory-item:not(.hidden) {
    animation: popIn 0.5s ease;
}

@keyframes popIn {
    0% { transform: scale(0); }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Quiz panel */
#quizPanel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: absolute;
    top: 50px;
    left: 8px;
    right: 8px;
    bottom: 60px;
    z-index: 10;
}

#quizQuestion {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 12px;
    text-align: center;
    color: #333;
}

#quizOptions {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.quiz-option {
    background: linear-gradient(145deg, #ffffff, #f5f5f5);
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    transition: all 0.3s ease;
    min-height: 36px;
}

.quiz-option:hover {
    border-color: #2196f3;
    transform: translateY(-1px);
}

.quiz-option.correct {
    background: linear-gradient(145deg, #e8f5e8, #c8e6c9);
    border-color: #4caf50;
}

.quiz-option.incorrect {
    background: linear-gradient(145deg, #ffebee, #ffcdd2);
    border-color: #f44336;
}

#quizFeedback {
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    min-height: 20px;
}

/* Badge panel for achievements */
#badgePanel {
    position: absolute;
    top: 40px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 5;
}

.badge {
    background: linear-gradient(145deg, #ffd700, #ffb300);
    color: #333;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
    animation: badgeAppear 0.8s ease;
    white-space: nowrap;
}

@keyframes badgeAppear {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(90deg); opacity: 0.8; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Tooltip for additional information */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Mobile-first responsive design */
@media (max-width: 480px) {
    #gameContainer {
        padding: 5px;
        gap: 5px;
    }
    
    .tap-button {
        padding: 8px 4px;
        min-height: 55px;
    }
    
    .tap-emoji {
        font-size: 20px;
    }
    
    .tap-name {
        font-size: 10px;
    }
    
    #storyText {
        font-size: 13px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .tap-button, .decision-button, .quiz-option {
        min-height: 44px; /* Apple's recommended touch target size */
    }
    
    .tap-button:active {
        background: linear-gradient(145deg, #e3f2fd, #bbdefb);
    }
}